import { _decorator, Component, find, instantiate, Node, Prefab, RigidBody } from 'cc';
import { Weapon } from './Weapon';
import { Arrow } from './Arrow';
const { ccclass, property } = _decorator;

@ccclass('Weapon_NJ')
export class Weapon_NJ extends Weapon {
    @property(Prefab)
    ArrowPrefab: Prefab = null;

    attack(): void {
        super.attack();
        this.playAttackAni();
        this.node.setRotationFromEuler(0, 0, this.getRotateToTarget());//转向
        this.fireArrow();
    }
    fireArrow() {
        let arrowNode: Node = instantiate(this.ArrowPrefab);
        if (this.node.parent) {
            this.node.parent.addChild(arrowNode);
            arrowNode.position = this.node.position.clone();
            arrowNode.getComponent(Arrow).fire(this.getRotateToTarget(), this.Harm, this.node.position.clone());
        }
    }
}


